local M = {
    'petertriho/nvim-scrollbar',
    event = 'VeryLazy',
    -- enabled = false,
}

function M.config()
    require('scrollbar.handlers.search').setup()
    require('scrollbar').setup({
        show = true,
        set_highlights = true,
        folds = 1000, -- handle folds, set to number to disable folds if no. of lines in buffer exceeds this
        max_lines = false, -- disables if no. of lines in buffer exceeds this
        -- handle = {
        --     text = ' ',
        --     -- color = '#7E7567',
        --     cterm = nil,
        --     highlight = 'CursorColumn',
        --     hide_if_all_visible = true, -- Hides handle if all lines are visible
        -- },
        marks = {
            Search = {
                text = { '-', '=' },
                priority = 0,
                color = '#ff9e64',
                cterm = nil,
                highlight = 'Search',
            },
            Error = {
                text = { '-', '=' },
                priority = 1,
                color = '#f7768e',
                cterm = nil,
                highlight = 'DiagnosticVirtualTextError',
            },
            Warn = {
                text = { '-', '=' },
                priority = 2,
                color = '#e0af68',
                cterm = nil,
                highlight = 'DiagnosticVirtualTextWarn',
            },
            Info = {
                text = { '-', '=' },
                priority = 3,
                color = '#0db9d7',
                cterm = nil,
                highlight = 'DiagnosticVirtualTextInfo',
            },
            Hint = {
                text = { '-', '=' },
                priority = 4,
                color = '#1abc9c',
                cterm = nil,
                highlight = 'DiagnosticVirtualTextHint',
            },
            Misc = {
                text = { '-', '=' },
                priority = 5,
                color = '#9d7cd8',
                cterm = nil,
                highlight = 'Normal',
            },
        },
        excluded_buftypes = {
            'terminal',
        },
        excluded_filetypes = {
            'prompt',
            'TelescopePrompt',
            'NvimTree',
        },
        autocmd = {
            render = {
                'BufWinEnter',
                'TabEnter',
                'TermEnter',
                'WinEnter',
                'CmdwinLeave',
                'TextChanged',
                'VimResized',
                'WinScrolled',
            },
        },
        handlers = {
            diagnostic = true,
            search = true, -- Requires hlslens to be loaded, will run require("scrollbar.handlers.search").setup() for you
        },
    })
end

return M
